package com.xmu.prcs.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
 * 角色表
 * @author frequent
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "role", uniqueConstraints = @UniqueConstraint(columnNames = "rolename"))
public class Role implements Serializable {

	private Integer idRole;
	private String roleName;//角色名
	private Integer level;//角色等级
	private String roleInfo;//角色介绍
	private Set<Permission> permissons;//角色拥有的权限
	
	public Role(){
		
	}
	public Role(String info){
		this.roleInfo = info;
	}
	
	@Id
	@GeneratedValue
	@Column(name = "idrole", unique = true, nullable = true)
	public Integer getIdRole() {
		return idRole;
	}
	public void setIdRole(Integer idRole) {
		this.idRole = idRole;
	}
	
	@Column(name = "rolename", length = 20)
	public String getRoleName() {
		return roleName;
	}
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	
	@Column(name = "level")
	public Integer getLevel() {
		return level;
	}
	public void setLevel(Integer level) {
		this.level = level;
	}
	
	@Column(name = "roleinfo", length = 50)
	public String getRoleInfo() {
		return roleInfo;
	}
	public void setRoleInfo(String roleInfo) {
		this.roleInfo = roleInfo;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "idrole")
	public Set<Permission> getPermissons() {
		return permissons;
	}
	public void setPermissons(Set<Permission> permissons) {
		this.permissons = permissons;
	}
	
}
